package com.atguigu.gmall.file;


import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

import java.io.IOException;

public class FileUploadDemo {

    public static void main(String[] args) throws Exception {

        //配置跟踪器的ip以及端口
        String path = ClassUtils.getDefaultClassLoader()
                .getResource("fdfs_client.conf").getPath();
        ClientGlobal.init(path);

        //1.创建TrackerClient 客户端
        TrackerClient trackerClient = new TrackerClient();
        //2.连接TrackerServer端
        TrackerServer trackerServer = trackerClient.getConnection();

        //3.创建Storage的客户端
        StorageServer storageServer = null;
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,storageServer);
        //4.上传文件
        String fileId = storageClient1.upload_file1("D:\\壁纸\\1q.jpg", "jpg", null);
        System.out.println("http://192.168.6.133:8080/"+fileId);
    }

}
